#获取采购订单表
import json
from flask import request
from db_client import *

def get_order():
        po_number = request.args.get('search')
        results = mysql_client.get_order(po_number)
        orders = []
        for result in results:
                t = {
                        "order_id" : result[0],
                        "supplier_id" : result[1],
                        "state" : result[2],
                        "item_id" : result[3],
                        "pruchase_count" : result[4],
                        "accepted_count" : result[5],
                        "unit_price" : result[6],
                        "total_price" : result[7],
                        "plan_id" : result[8],
                        "item_name" : result[9]
                }
                orders.append(t)
        data = orders
        return json.dumps(data,ensure_ascii=False)